// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import BannerAd from "./BannerAd";
import TreasureBox from "./TreasureBox";

const { ccclass, property } = cc._decorator;

@ccclass
export default class MainScene extends cc.Component {

    @property(cc.Node)
    yinSi: cc.Node;
    @property(cc.Node)
    yszc: cc.Node;
    @property(cc.Node)
    lxkf: cc.Node;
    @property(cc.Node)
    gdjc: cc.Node;
    @property(cc.Node)
    zxzh: cc.Node;

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        BannerAd.Instance.GetcityIswhite();
    }

    start() {
        if (BannerAd.Instance.cityIswhite) BannerAd.Instance.ShowBanner();
        if (cc.sys.platform == cc.sys.ANDROID) {
            // this.yszc.active = false;
            // this.lxkf.active = false;
            // this.gdjc.active = false;
            var result = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "JudgeChannel", "()Ljava/lang/String;");
            switch (result) {
                case "VivoBtn":
                    this.gdjc.active = false;
                    break;
                case "OppoBtn":
                    break;
                case "HuaweiBtn":
                    this.lxkf.active = false;
                    this.gdjc.active = false;
                    this.zxzh.active = true;
                    break;
                default:
                    this.yszc.active = false;
                    this.lxkf.active = false;
                    this.gdjc.active = false;
                    break;
            }
        }
        else {
            this.lxkf.active = false;
            this.gdjc.active = false;
        }
    }

    // update (dt) {}

    Play() {
        function fun() {
            cc.director.loadScene("FirstLoad");
        }
        BannerAd.Instance.ShowCustomAd();
        if (BannerAd.Instance.cityIswhite) TreasureBox.Show(fun);
        else fun();
    }

    YinSi() {
        if (BannerAd.Is_ANDROID) BannerAd.Instance.AndriodPrivacy();
        else this.yinSi.active = true;
    }

    Kefu() {
        BannerAd.Instance.AndroidKeFu();
    }

    More() {
        BannerAd.Instance.AndroidMoreGame();
    }

    Quit() {
        BannerAd.Instance.AndroidLogout();
    }
}
